<?php

namespace App\Http\Controllers;

use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Support\Facades\DB;

class Controller extends BaseController
{
    use AuthorizesRequests, DispatchesJobs, ValidatesRequests;


    public function OkJson($code=200,$msg='',$data)
    {
        return response()->json([
            'code' => 200,
            'msg' => $msg,
            'data'=>$data
        ]);

    }
    public function ErrJson($code,$msg){
        return response()->json([
            'code' => intval($code),
            'msg' => $msg,
            'data'=> new \stdClass()
        ]);
    }

    public function isLogin($token){
        if(empty($token)){
            return false;
        }
        $user_info = DB::table('users')->where('token',$token)->first();
        if(empty($user_info)){
            return false;
        }
        return $user_info;
    }

}
